package y23.Sep;

public class Test14 {
    public static void main(String[] args) {
        System.out.println(dayOfYear("2019-01-09"));
        System.out.println(dayOfYear("2019-02-10"));
    }
    public static int dayOfYear(String date) {
        int[] monthArr = {31,28,31,30,31,30,31,31,30,31,30,31};
        int year = Integer.parseInt(date.substring(0,4));
        if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
            monthArr[1] = 29;
        }
        int month = Integer.parseInt(date.substring(5,7));
        int day = Integer.parseInt(date.substring(8));
        int sum = 0;
        for(int i = 1;i < month;i++){
            sum += monthArr[i-1];
        }
        return sum + day;
    }
}
